﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace MoodleDesktop
{
    public partial class MenuItem : UserControl
    {
        public bool isExtand = false;
        public fmForum mainform{ get; set; }
        public System.Windows.Forms.Timer t;
        public int time;
        public int a;
        public int v;
        public int s;
        public int y_Cuoi;
        public Thread thread;
        public MenuItem()
        {
            InitializeComponent();
            v = 60;
            a = 20;

        }


        public delegate void onUserClick(object sender, EventArgs e);

        public onUserClick mySender;
        private void txt_content_Click(object sender, EventArgs e)
        {
            this.mySender(sender, e);
        }

        private void MenuItem_Click(object sender, EventArgs e)
        {
            //onUserClick(sender, e);
        }

        private void btn_expand_Click(object sender, EventArgs e)
        {
            this.mySender(sender, e);
        }

        public void DiChuyenDung(int diemCuoi)
        {
            y_Cuoi = diemCuoi;
            t = new System.Windows.Forms.Timer();
            t.Interval = 1;
            t.Tick += new EventHandler(t_Tick);
            t.Start();
            
        }

        public void t_Tick(object sender, EventArgs e)
        {
            v = v + a;
            this.Location = new Point(this.Location.X, this.Location.Y + v);
           
            if (this.Location.Y >= y_Cuoi)
            {
                
                this.Location = new Point(this.Location.X, y_Cuoi);
                t.Stop();
                t.Dispose();
                //v = -v;
                //a = a * 2;
                //if (a >= 50)
                //{
                //    a = 5;
                //    v = 10;
                //    t.Stop();
                //    t.Dispose();
                //}
                
            }

        }
        
       
    }
}
